package test;

public class MaHoa {
	public static String maHoa(String key, String data) {
		String chuoiDaMaHoa = "";
		int indexKey = 0;
		for (int i = 0; i < data.length(); i++) {
			char a = data.charAt(i);
			if (indexKey == key.length()) {
				indexKey = 0;
			}
			char b = key.charAt(indexKey);

			char c = (char) (((int) a ^ (int) b) + 150);
			chuoiDaMaHoa += c;
			indexKey += 1;
		}
		return chuoiDaMaHoa;
	}

	public static String giaiMa(String key, String data) {
		String chuoiGiaMa = "";
		int indexKey = 0;
		try {
			for (int i = 0; i < data.length(); i++) {
				char a = data.charAt(i);
				if (indexKey == key.length()) {
					indexKey = 0;
				}

				a -= 150;
				char b = key.charAt(indexKey);

				char c = (char) ((int) a ^ (int) b);
				chuoiGiaMa += c;
				indexKey += 1;
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		return chuoiGiaMa;
	}

//	public static void main(String[] args) {
//		String a = maHoa("147852369lenhan",
//				"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
//		String b = giaiMa("147852369lenhan", a);
//		System.out.println(a);
//		System.out.println(b);
//	}
	public static void main(String[] args) {
		System.out.println("aa");
	}

}
